﻿// DColumn简历列表表头项目下拉JS
/**
*@param o DColumn对象变量名称
*@param t 所在的Table Id
*@param s 需要进行变化选项的select选择框id,数组形式
*@param h 隐藏域Id
*@param c 下拉选择框select的位置,数组形式
*@param d 需要选择显示的显示项位置及显示名称
*@param n 初始化显示的显示项
**/
  var allData = { 12: '人数', 13: '起始日期', 14: '截止日期', 15: '起止天数', 16: '创利金额', 17: '奖励金额', 18: '导游类型', 19: '所属团队' };
  function DColumn(o, t, s, h, c, d, n) {
	  this.o = o;
	  this.t = document.getElementById(t);
	  var i;
	  this.s = new Array();
	  for (i = 0; s[i]; i++) this.s[this.s.length] = document.getElementById(s[i]);
	  this.h = document.getElementById(h);
	  this.c = c;
	  this.d = d;
	  this.n = n;
  }
  DColumn.prototype.init = function() {
	  var cookieStr = getCookie(cvTabDefColCookieName);
	 if(cookieStr!=null && cookieStr!=''){
	var data4cookie = cookieStr.toString().split(',');
	if(data4cookie.length<this.n.length){
		var fixCookieV = ','+cookieStr+',';
		for(var z=0;this.n[z];z++) if(fixCookieV.indexOf(','+this.n[z]+',')==-1){
			fixCookieV += this.n[z];
			break;
		}
		fixCookieV = fixCookieV.substring(1);
		data4cookie = fixCookieV.split(',');
	}
	this.n = data4cookie;
}
	  if (this.h.value != '') this.n = this.h.value.toString().split(',');
	  var i, j, r, o;
	  o = eval(this.o);
	  for (i = 0; this.s[i]; i++) this.s[i].options[0] = new Option(this.d[this.n[i]], this.n[i]);
	  for (j in this.d) if (this.check(j)) for (i = 0; this.s[i]; i++) this.s[i].options[this.s[i].length] = new Option(this.d[j], j);
	  for (i = 1; i < this.t.rows.length - 1; i++) {
		  r = this.t.rows[i];
		  if(r.cells.length<10) continue;
		  for (j = 0; this.c[j]; j++) {
			  r.cells[this.c[j]].innerHTML = r.cells[this.n[j]].innerHTML;
			  r.cells[this.c[j]].title = r.cells[this.n[j]].title;
		  }
	  }
	  this.s[0].onchange = function(){o.changeSel(0,this);}
	  this.s[1].onchange = function(){o.changeSel(1,this);}
	  this.s[2].onchange = function(){o.changeSel(2,this);}
	  /* this.s[3].onchange = function(){o.changeSel(3,this);} */
  }
  DColumn.prototype.changeSel = function(c, s) {
	  var i, j, r;
	  for (i = 0; this.s[i]; i++) if (this.s[i].id != s.id) for (j = 0; j < this.s[i].length; j++) if (this.s[i].options[j].value == s.value) {
		  this.s[i].options[j].value = this.n[c];
		  this.s[i].options[j].text = this.d[this.n[c]];
	  }
	  for (i = 1; i < this.t.rows.length - 1; i++) {
		  r = this.t.rows[i];
		  if(r.cells.length<10) continue;
		  r.cells[this.c[c]].innerHTML = r.cells[s.value].innerHTML;
		  r.cells[this.c[c]].title = r.cells[s.value].title;
	  }
	  this.n[c] = s.value;
	  this.h.value = this.n.join(',');
	  document.cookie = cvTabDefColCookieName + '=' + this.h.value + '; path=/; expires=Sun, 18 Jan 2038 00:00:00 GMT; domain=jjrw.com';
  }
  DColumn.prototype.check = function(t) {
	  var i;
	  for (i = 0; i < this.n.length; i++) if (t == this.n[i]) return false;
	  return true;
  }
  var myDColumn = new DColumn('myDColumn','TalentResumeList',['DColumn_sel0','DColumn_sel1','DColumn_sel2'],'DColumn_hidden',[7,8,9],allData,[12,16,17]); /*第7、8、9项为需要进行变化选项，初始化显示11、12、13项*/
  /* var myDColumn = new DColumn('myDColumn','TalentResumeList',['DColumn_sel0','DColumn_sel1','DColumn_sel2','DColumn_sel3'],'DColumn_hidden',[6,7,8,9],allData,[13,14,15,16]);   第6、7、8、9项为需要进行变化选项，初始化显示13、14、15、16项*/
  myDColumn.init();
  function selTimeSpan_onchange() {
	  document.TalentLibForm.PageType.value = "0"
	  document.TalentLibForm.SelectIndex_Opt.value = document.TalentLibForm.selTimeSpan.selectedIndex
	  document.TalentLibForm.submit();
	 // var htmlEle = document.TalentLibForm.selTimeSpan; var timeTxt = htmlEle.options[htmlEle.selectedIndex].text
  }